<extend name="Public/base"/>
  
<block name="body">
	<div class="main-title">
        <h2>编辑首页幻灯片广告</h2>
    </div>
	<script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>           
    <form class="form-horizontal" role="form" action="{:U('Ad/edit')}" method="post" enctype="multipart/form-data"> 
        <div class="form-group">
        	<label class="col-sm-2 control-label" for="ad-title">广告标题</label>
        	<div class="col-sm-10">
        		<input class="form-control" type="text " id="ad-title" value="{$ad[title]}" name="title">
        	</div>
        </div>
        <div class="form-group">
       		 <label class="col-sm-2 control-label" for="form-field-1">广告图片<span style="color:#f00;">*</span></label>
			 <div class="col-sm-10">
				<input type="file" id="upload_picture_pic_url" class="form-control">
				
				<div class="upload-img-box">
				<notempty name="ad.pic_url">
					<div class="upload-pre-item"><img src="{:get_image_url($ad[pic_url])}"/></div>
				</notempty>
				</div>
			 </div>	
			<script type="text/javascript">
			//上传图片
			   /* 初始化上传插件 */
			$("#upload_picture_pic_url").uploadify({
			       "height"          : 30,
			       "swf"             : "__STATIC__/uploadify/uploadify.swf",
			       "fileObjName"     : "download",
			       "buttonText"      : "上传图片",
			       "uploader"        : "{:U('File/uploadAdPicture',array('session_id'=>session_id()))}",
			       "width"           : 120,      
			       "removeTimeout"	  : 1,
			       "fileTypeExts"	  : "*.jpg; *.png; *.gif;",
			       "onUploadSuccess" : uploadPicture,
			       "onFallback" : function() {
			           alert('未检测到兼容版本的Flash.');
			       }
			   });
			function uploadPicture(file, data){
			   	var data = $.parseJSON(data);
			   	var src = '';
			   	
			       if(data.status){
			       	
			       	$("#pic_url").val(data.path);
			       	src = data.url || '__ROOT__' + data.path
			      
			       	$('.upload-img-box').html(
			       		'<div class="upload-pre-item"><img src="' + src + '"/></div>'
			       	);
			       } else {
			       	updateAlert(data.info);
			       	setTimeout(function(){
			               $('#top-alert').find('button').click();
			               $(that).removeClass('disabled').prop('disabled',false);
			           },1500);
			       }
			   }
			</script>
		</div>
        <div class="form-group">
            <label class="col-sm-2 control-label " for="form-field-1">远程图片</label>
            <div class="col-sm-10">
            	<input class="col-sm-12 form-control" type="text" name="pic_url" id="pic_url" value="{$ad[pic_url]}"/>
            </div>
        </div>          
        <div class="form-group">
            <label class="col-sm-2 control-label " for="form-field-1">链接<span style="color:#f00;">*</span></label>
            <div class="col-sm-10">
            	<input class="col-sm-12 form-control" type="text" name="link" value="{$ad['link']}">
            </div>
        </div>
  
        <div class="clearfix form-actions">
            <div class="col-md-offset-4 col-md-4">
            	<input type="hidden" name="id" value="{$ad.id}">
                <button class="btn btn-info btn-block ajax-post" target-form="form-horizontal" type="submit">
                    <i class="icon-ok bigger-110"></i>
                    确认
                </button>
            </div>
        </div>
    </form>
                       
   
 </block>
    <a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
        <i class="icon-double-angle-up icon-only bigger-110"></i>
    </a>
<script>
    $(function () {
        highlight_subnav('{:U('Goods/edit')}');
    });
</script>
